using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace QLThuHocPhi
{
    public partial class FormThongKe : Form
    {
        public FormThongKe()
        {
            InitializeComponent();
        }
        QLThuHocPhi.Database.DBTool dbt = new QLThuHocPhi.Database.DBTool();
        private void FormThongKe_Load(object sender, EventArgs e)
        {
            LoadComboKhoa();
            LoadComboKhoaHoc();
           // chitiet();

        }
        private void LoadComboMon(int makhoa) {
            DataSet ds1 = new DataSet();
            ds1 = dbt.GetMonHoc(makhoa);
            this.cbMon.DataSource = ds1.Tables["Monhoc"];
            this.cbMon.DisplayMember = "TenMonHoc";
            this.cbMon.ValueMember = "Mamon";
        }
        private void LoadComboKhoa() {
            DataSet ds1 = new DataSet();
            ds1 = dbt.GetListKhoa();
            this.cbKhoa.DataSource = ds1.Tables["Khoa"];
            this.cbKhoa.DisplayMember = "TenKhoa";
            this.cbKhoa.ValueMember = "Makhoa";
        }

        private void cbKhoa_SelectedValueChanged(object sender, EventArgs e)
        {
            try
            {
                int makhoa = int.Parse(cbKhoa.SelectedValue.ToString());
                LoadComboMon(makhoa);
            }
            catch (Exception ex){ }
        }
        private void LoadComboKhoaHoc() {
            DataSet ds1 = new DataSet();
            ds1 = dbt.LoadKhoahoc1();
            this.cbKhoaHoc.DataSource = ds1.Tables["khoahoc1"];
            this.cbKhoaHoc.DisplayMember = "KhoaHoc";
            this.cbKhoaHoc.ValueMember = "Makhoahoc";
        }

        private void button1_Click(object sender, EventArgs e)
        {
            
            string monhoc = cbMon.Text;
            string khoahoc = cbKhoaHoc.Text;
            string khoa = cbKhoa.Text;
            DateTime ngaybd = DateTime.Parse(dtTungay.Text);
            DateTime ngaykt = DateTime.Parse(dtDenngay.Text);
            DataSet ds =dbt.LoadThongKe(monhoc, khoa, khoahoc, ngaybd, ngaykt);
            CrystalReport3 rp = new CrystalReport3();
            rp.SetDataSource(ds);
            crystalReportViewer1.ReportSource = rp;
            
           // ds.WriteXml("C:/Data.xml");
        }
        private void chitiet() {
            DataSet ds = new DataSet();
            ds = dbt.Chitiethocphi();
            CrystalReport3 rp = new CrystalReport3();
            rp.SetDataSource(ds);
            crystalReportViewer1.ReportSource = rp;
        }
        private void button2_Click(object sender, EventArgs e)
        {
           // chitiet();  
        }
    }
}